package com.thb.pay.manage.web.merchant;


import com.thb.pay.api.merchant.MchInfoServiceApi;
import com.thb.pay.api.merchant.vo.req.MchInfoPageReq;
import com.thb.pay.api.merchant.vo.req.MchInfoReq;
import com.thb.pay.api.merchant.vo.resp.MchInfoVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户-信息表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@RestController
@RequestMapping("/api/sys/mchInfo")
public class MchInfoController {

    @Autowired
    private MchInfoServiceApi mchInfoServiceApi;

    @PostMapping("/list")
    public R list(@RequestBody MchInfoPageReq pageReq) {
        PageResult<MchInfoVo> pageResult = mchInfoServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    @RequestMapping("/get")
    public R get(@RequestParam("id") Long id) {
        MchInfoVo resultData = mchInfoServiceApi.getById(id);
        return R.okData(resultData);
    }

    @PostMapping("/add")
    public R add(@RequestBody MchInfoReq mchInfoReq) {
        mchInfoServiceApi.add(mchInfoReq);
        return R.ok();
    }

    @PostMapping("/update")
    public R update(@RequestBody MchInfoReq mchInfoReq) {
        mchInfoServiceApi.update(mchInfoReq);
        return R.ok();
    }
}
